package program;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

import com.appress.hibernate.CATALOGS;

public class Main {

	public static void main(String[] args) {
		System.out.println("Hello hibernate");
	
		SessionFactory sessions=
				new AnnotationConfiguration().configure().buildSessionFactory();
		
		Session session=sessions.openSession();
		
		session.beginTransaction();
		List<CATALOGS> list=session.createQuery("from CATALOGS").list();
		session.getTransaction().commit();
		
		session.close();
		
		for(CATALOGS item : list){
			
			System.out.println(item.getId() +" "+item.getName());
			
		}
	}
}
